/*******************************************************************************************************
Last Descriptive Stats with Subsample
**********************************************************************************************************
This file uses the following datasets:
	-GAIM_HH_PlotHist_BG_Cleaned_AG_PlotAlign_plotlevel_anonymized.dta
	-final_crosswalk_withplotownership_v2_withsubsample_v2.dta
	

*/
/***************************************************
discordance on number of plots owned by household
****************************************************/

use "GAIM_HH_PlotHist_BG_Cleaned_AG_PlotAlign_plotlevel_anonymized.dta", clear
collapse male_plot female_plot, by(hhid)
tab male_plot female_plot


/************************************************
ownership discordance tables
**************************************************/

//// Intra-Couple Dissent on Ownership Table ///

use "final_crosswalk_withplotownership_v2_withsubsample_anonymized_v2.dta", clear

keep if both_90==1 & subsample==1 & subsample_spouse==1

//// Today //////

**Data Prep
 
gen femaleownership_malereport=.

replace femaleownership_malereport=1 if male_ownership_today==3
replace femaleownership_malereport=2 if inlist(male_ownership_today,4,5)
replace femaleownership_malereport=3 if inlist(male_ownership_today,2,1,0)

gen femaleownership_femalereport=.

replace femaleownership_femalereport=1 if female_ownership_today==2
replace femaleownership_femalereport=2 if inlist(female_ownership_today,1,5)
replace femaleownership_femalereport=3 if inlist(female_ownership_today,0,3,4)

gen maleownership_malereport=.

replace maleownership_malereport=1 if male_ownership_today==2
replace maleownership_malereport=2 if inlist(male_ownership_today,1,5)
replace maleownership_malereport=3 if inlist(male_ownership_today,0,3,4)

gen maleownership_femalereport=.

replace maleownership_femalereport=1 if female_ownership_today==3
replace maleownership_femalereport=2 if inlist(female_ownership_today,4,5)
replace maleownership_femalereport=3 if inlist(female_ownership_today,0,1,2)

**Tabs for Table


tab femaleownership_malereport femaleownership_femalereport
tab maleownership_malereport maleownership_femalereport



/***********************************
overlap analysis with new crosswalk
*************************************/
use "final_crosswalk_withplotownership_v2_withsubsample_anonymized_v2.dta", clear

label var percent_intersect_f "Overlap / Female Walkpath Area"
label var percent_intersect_m "Overlap / Male Walkpath Area"

keep if subsample==1 & subsample_spouse==1

histogram percent_intersect_m, freq bin(40) graphregion(color(white))

graph export overlap_histogram_male.jpg, replace as(jpg) quality(100)
histogram percent_intersect_f, freq bin(40) graphregion(color(white))

graph export overlap_histogram_female.jpg, replace as(jpg) quality(100)
twoway scatter percent_intersect_m percent_intersect_f, graphregion(color(white))

graph export overlap_scatter.jpg, replace as(jpg) quality(100)
graph export overlap_scatter.pdf, replace as(pdf)


/******************************************
male/female maize productivity scatterplot
********************************************/

use "final_crosswalk_withplotownership_v2_withsubsample_anonymized_v2.dta", clear

gen maize_agree_man=0 
replace maize_agree_man=1 if I__AGa1_13a1_m==19 | I__AGb1_13a1_m==19 | I__AGc1_13a1_m==19 | I__AGd1_13a1_m==19

gen maize_agree_woman=0
replace maize_agree_woman=1 if I__AGa1_13a1_f==19 | I__AGb1_13a1_f==19 | I__AGc1_13a1_f==19 | I__AGd1_13a1_f==19

gen maize_agree=0
replace maize_agree=1 if maize_agree_man==1 & maize_agree_woman==1

 
// 
gen maize_productivity_actualarea_f = maize_harvested_ifplanted_f/(area_f/4046.86)
label var maize_productivity_actualarea_f "Female Reported Maize Productivity (kg/acre)"

gen maize_productivity_actualarea_m = maize_harvested_ifplanted_m/(area_m/4046.86)
label var maize_productivity_actualarea_m "Male Reported Maize Productivity (kg/acre)"

// Same scatterplot will be produced as in report, but female reported productivity was relabeled to the y-axis, and male reported productivity was relabeled to the x-axis

twoway (scatter maize_productivity_actualarea_f maize_productivity_actualarea_m if maize_agree==1 & both_90==1 & subsample==1 & subsample_spouse==1) (function y=x, range(0 1500)),graphregion(color(white)) 
graph export "maize_productivity_scatter_both90.pdf", replace

